knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
#packages to attach
library(tidyverse)
library(here)
library(sf)
library(janitor)
library(tmap)
#Read in the data for CA DFW oil spills
oil_spills_sf <- read_sf(here("data", "ds394.shp")) %>%
clean_names()
counties_sf <- read_sf(here("data", "ca_counties", "CA_Counties_TIGER2016.shp"))
counties_sf_subset <- counties_sf %>%
select(NAME, ALAND) %>%
rename(county_name = NAME, land_area = ALAND)
# Check CRS:
#counties_sf %>% st_crs()
#oil_spills_sf %>% st_crs()
# Set CRS of oil_spills to be same as counties
oil_spills_sf <- st_transform(oil_spills_sf, st_crs(counties_sf))
# Re-check CRS:
#oil_spills_sf %>% st_crs()
An interactive map, using tmap to show the location of oil spill events in California.
# Set the viewing mode to interactive:
tmap_mode(mode = "view")
# Make the map:
tm_shape(counties_sf_subset) +
tm_borders() +
tm_shape(oil_spills_sf) +
tm_dots(col = "royalblue4")